package hot100.h0911;
/**
  * @description 搜索二维矩阵
  * @author 不知名帅哥
  * @date 2024/9/11 21:57
  * @version 1.0
*/
public class SearchMatrix {
    public static void main(String[] args) {

    }
    public boolean searchMatrix(int[][] matrix, int target) {
        int row=matrix.length;
        int col=matrix[0].length;

        int i=0;
        int j=col-1;
        while (i<row&&j>=0){
            if (matrix[i][j]==target){
                return true;
            }else if (matrix[i][j]>target){
                j--;
            }else {
                i++;
            }
        }
        return false;
    }
}
